//
//  IvcsAgent.h
//  IVCS
//
//  Created by nfl on 2022/2/28.
//  Copyright © 2022 zco user. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "IvcsAgentDelegate.h"
#import "ZcoModelScenarioBrief.h"
#import "ZcoModelScenariosEnable.h"
#import "ZcoModelRing.h"
#import <IVCS/ZcoModelUserInfo.h>
#import <IVCS/MediaStreamSettingOptions.h>
#import <IVCS/CallBackObject.h>
NS_ASSUME_NONNULL_BEGIN

@interface IvcsAgent : NSObject

@property(nonatomic , strong) id<IvcsAgentDelegate> delegate;

declareSingleInstance(Agent)

/// 访客初始化并连接 CCS
/// @param serviceUrl 账号系统的后台地址
/// @param name 访客登录用户名
/// @param password 访客登录密码
/// @param org 访客所属机构名
/// @param mediaOptions 访客视频流的设置
/// @param onSuccess 初始化成功，返回用户基本信息
/// @param onFailure 初始化失败，返回错误信息
-(void)initWithServiceUrl:(NSString *)serviceUrl
        name:(NSString *)name
        password:(NSString *)password
        org:(NSString *)org
        mediaOptions:(MediaStreamSettingOptions *__nullable)mediaOptions
        onSuccess:(void (^)(ZcoModelUserInfo *userInfo))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;

/// connect ams socketio
/// @param baseUrl url
/// @param token access token
/// @param complete callback
-(void)loginWithUrl:(nonnull NSString *)baseUrl andToken:(nonnull NSString *)token complete:(completeBlock)complete;

/// 根据坐席名称获取已开启的场景列表
-(void)getBusinessScenariosByAgentName:(NSString *)agentName onSuccess:(void (^)(ZcoModelScenariosEnable * _Nonnull))onSuccess onFailure:(void (^)(NSError * _Nonnull))onFailure;

/// 获取可用的场景列表
-(void)getBusinessScenarios:(void (^)(NSMutableArray<ZcoModelScenarioBrief *> * _Nonnull))onSuccess onFailure:(void (^)(NSError * _Nonnull))onFailure;

/// 签入场景分组
/// @param complete callback
-(void)checkIn:(nonnull NSArray<NSNumber *> *) scenrioIds complete:(completeBlock)complete;

/// 签出场景分组
/// @param complete callback
-(void)checkOut:(nonnull NSArray<NSNumber *> *) scenrioIds complete:(completeBlock)complete;
/// 小休操作

/// @param dic scenrioIds description

/// @param complete complete description

-(void)getRelax:(NSDictionary *) dic complete:(completeBlock)complete;
/// 准备好接听通话
/// @param complete callback
-(void)ready:(completeBlock)complete;
/// 未准备

/// @param complete callback

-(void)unready:(completeBlock)complete;
/// 发送手写签名消息(这里使用的是 fabric3.4 方案
/// @param roles 发送给角色 agents/customers(默认 agents)
- (void)acceptHandWritingMessage:(NSString * _Nullable)msg to:(NSString *__nullable)roles;
/// 接听呼叫
- (void)answer:(IRTCCameraPreviewView *_Nullable)view complete:(completeBlock)complete;

/// 订阅并渲染远端流
/// @param label 流标签
/// @param renderer 渲染的控件
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)renderStreamWithLabel:(NSString *)label renderView:(NSObject<IRTCVideoRenderer>*)renderer onSuccess:(void (^)(void))onSuccess onFailure:(void (^)(NSError * _Nonnull))onFailure;

/// 房间本身就有流，坐席作为三方或者邀请
/// @param stream 已存在的流
/// @param label 流标签
/// @param renderer 渲染的控件
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)renderStreamWithStream:(IRTCRemoteStream *)stream AndLabel:(NSString *)label renderView:(NSObject<IRTCVideoRenderer>*)renderer onSuccess:(void (^)(void))onSuccess onFailure:(void (^)(NSError * _Nonnull))onFailure;

-(void)shareScreenMethod;

/// 绑定特定 label 的流（已订阅或本地流）到 view
/// @param label 流标签
/// @param view 渲染的控件
-(void)attachStreamWithLabel:(nonnull NSString *)label
                   renderView:(NSObject<IRTCVideoRenderer> *)view;

/// 退出会话
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)quitSession:(void (^)(void))onSuccess
                onFailure:(void (^)(NSError *error))onFailure;
/// 发送自定义消息
/// @param data 消息内容
/// @param roles 发送给角色 agents/customers , 默认是 agents
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendCustomMessage:(id)data
        toRoles:(NSString * __nullable)roles
        onSuccess:(void (^__nullable)(void))onSuccess
        onFailure:(void (^__nullable)(NSError *error))onFailure;


/// 发送文本消息
/// @param data 消息内容
/// @param roles 发送给角色 agents/customers, 默认是 agents
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendTextMessage:(NSString *)data
        toRoles:(NSString * __nullable)roles
        onSuccess:(void (^)(void))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;

/// 分享url资源文件给对方

/// @param type 资源类型 ['doc','pic','video','aduio','page','paper']

/// @param url 资源地址

/// @param name 资源名字

/// @param roles 发送给角色 agents/customers

/// @param onSuccess 成功

/// @param onFailure 失败

-(void)shareResourceWithType:(NSString *)type

                 resourceUrl:(NSString *)url

                 resourceName:(NSString *)name

                 toRoles:(NSString *)roles

                 onSuccess:(void (^)(void))onSuccess

                 onFailure:(void (^)(NSError *error))onFailure;



/// 分享资源文件

/// @param type 文件类型  ['doc','pic','video','aduio','page','paper']

/// @param uploadUrl 上传的url

/// @param fileData fileData

/// @param fileName 文件名

/// @param mimeType 文件类型

/// @param roles 发送给对方的角色 默认是agents

/// @param onSuccess 成功

/// @param onFailure 失败

-(void)shareResourceWithType:(NSString *)type

            uploadUrl:(NSString *)uploadUrl

            fileData:(NSData *)fileData

            fileName:(NSString *)fileName

            mimeType:(NSString *)mimeType

            toRoles:(NSString *)roles

            onSuccess:(void (^)(void))onSuccess

            onFailure:(void (^)(NSError *error))onFailure;

/// 响应指令
/// @param cmd 指令
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
- (void)sendPeerResponse:(ZcoModelCMD *)cmd to:(NSString *__nullable)roles onSuccess:(void (^__nullable)(void))onSuccess onFailure:(void (^__nullable)(NSError * _Nonnull error))onFailure;

/// 获取本地视频流的快照
-(void)getSnapShotImage:(void (^)(UIImage*))onSuccess onFailure:(void (^)(NSError*))onFailure;

@end

NS_ASSUME_NONNULL_END
